var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        });
Object.defineProperty(o, "__esModule", {value: !0});
var n = t("BaseSdkMode"),
    r = t("GameCof"),
    s = (function (t) {
        i(e, t);
        function e() {
            return (null !== t && t.apply(this, arguments)) || this;
        }
        e.prototype.login = function () {
            var t = this;
            if ("undefined" != typeof AdView.Plat) {
                "oppo" == r.default.curPlat &&
                    AdView.Plat.login({
                        success: function (t) {
                            r.default.bindAccount = t.data.uid;
                        },
                        fail: function (t) {
                            console.log(t);
                        }
                    });
                if ("vivo" == r.default.curPlat) {
                    console.log("vivo登录");
                    AdView.Plat.getSystemInfoSync().platformVersionCode >= 1063 &&
                        AdView.Plat.login().then(
                            function (e) {
                                if (e.data.token) {
                                    console.log(e);
                                    AdView.Plat.getUserInfo().then(function (e) {
                                        console.log("vivo登录成功", e.nickName);
                                        r.default.bindAccount = e.nickName;
                                        t.requestLogin(
                                            r.default.getLastId(),
                                            r.default.getLastId(),
                                            r.default.bindAccount,
                                            null
                                        );
                                    });
                                }
                            },
                            function (t) {
                                console.log("登录失败" + JSON.stringify(t));
                            }
                        );
                }
                if ("tt" == r.default.curPlat) {
                    var e = function () {
                        AdView.Plat.authenticateRealName({
                            success: function () {
                                console.log("用户实名认证成功");
                            },
                            fail: function (t) {
                                console.log("用户实名认证失败", t.errMsg);
                            }
                        });
                    };
                    console.log("是抖音登录");
                    var o = {
                        force: !0,
                        success: function (t) {
                            console.log("登录成功", t, this);
                            AdView.Plat.getUserInfo({
                                withCredentials: !1,
                                withRealNameAuthenticationInfo: !0,
                                success: function (t) {
                                    "uncertified" == t.realNameAuthenticationStatus && AdView.Plat.onTouchEnd(e);
                                    console.log("getUserInfo 调用成功", t);
                                },
                                fail: function (t) {
                                    console.log("getUserInfo 调用失败", t.errMsg);
                                }
                            });
                        },
                        fail: function () {
                            console.log("login 调用失败");
                        }
                    };
                    AdView.Plat.login(o);
                }
            } else console.log("不是小游戏，安卓版本");
        };
        e.prototype.init = function () {
            if ("vivo" == r.default.curPlat) {
                console.log("vivo初始化");
                AdView.Plat.getSystemInfoSync().platformVersionCode >= 1063
                    ? AdView.Plat.onUpdateReady(function (t) {
                          if (1 == t) {
                              console.log("强制并更新版本");
                              AdView.Plat.applyUpdate();
                          }
                          0 == t && console.log("无更新");
                          2 == t && console.log("检查失败");
                          console.log("更新", JSON.stringify(t), t);
                      })
                    : console.log("平台版本国小，不执行强更");
            }
        };
        e.prototype.reissueReward = function () {};
        e.prototype.startAsynPay = function () {
            return !1;
        };
        e.prototype.requestLogin = function (t, e, o, a) {
            var i =
                r.default.baseUrlV3 +
                r.default.baseLibPathV3 +
                r.default.pathPlatformLogin2 +
                "?account=" +
                t +
                "&password=" +
                e +
                "&bindaccount=" +
                o +
                "&platform=" +
                r.default.platname +
                "&version=" +
                r.default.version +
                "&devid=" +
                AdView.devId +
                "&type=2&channel=" +
                r.default.channel +
                "&instime=" +
                r.default.gamecacheLoginType1Count +
                "&isclouds=" +
                r.default.isCloud;
            "" != r.default.token
                ? a && a("", r.default.token)
                : GameBaseManager.requestJson(
                      i,
                      function (t) {
                          console.log("GameBaseManager ------------ssss----- 登录结果", i + "\n", t);
                          if (1 == t.code) {
                              var e,
                                  o = t.data,
                                  a = o.token;
                              r.default.setLastLoginTime(o.lastlogintime);
                              r.default.backOrders = o.orders;
                              r.default.setToken(a);
                              GameBaseManager.lastLoginTime = o.lastlogintime;
                              r.default.loginAccount2 = o.bindaccount;
                              r.default.UID = o.uid;
                              o.fcm;
                              e = t.data.storageVer || 0;
                              if (1 == r.default.isCloud) {
                                  var n = t.data.storageAry;
                                  if (!(n && n.length > 0)) {
                                      console.log("云存储", "从云上同步", "没有数据");
                                      return;
                                  }
                                  var s = {};
                                  if (e >= r.default.getLoginDataVersion())
                                      for (var c = 0; c < n.length; c++) {
                                          var p = n[c],
                                              l = p.StorageKey,
                                              d = p.contents;
                                          p.deadline, p.encryptStr;
                                          s[l] = d;
                                      }
                                  console.log("GameBaseManager ----------------- saveObj", JSON.stringify(s));
                                  r.default.addCloudCache(s);
                              }
                              r.default.setLoginVersion(e + 1);
                          } else console.log("后端登录失败了");
                      },
                      this,
                      "POST",
                      function () {
                          console.log("后端登录请求失败");
                      }
                  );
        };
        e.reportEvents = function () {};
        e.storageData = function (t, e) {
            "vivo" == r.default.curPlat &&
                AdView.Plat.setStorage({
                    key: t,
                    value: e,
                    success: function (t) {
                        console.log("handling success" + e, JSON.stringify(t));
                    },
                    fail: function (t, e) {
                        console.log("handling fail, code = " + e);
                    }
                });
        };
        e.getStorageData = function (t) {
            "vivo" == r.default.curPlat &&
                AdView.Plat.getStorage({
                    key: t,
                    success: function (t) {
                        console.log("handling success", JSON.stringify(t));
                    },
                    fail: function (t, e) {
                        console.log("handling fail, code = " + e);
                    }
                });
        };
        return e;
    })(n.default);
o.default = s;
